<?php
namespace Plugin\Attractions\Commerce\Schema\Commerce_order_product;

use Plugin\Attractions\Commerce\Model\Commerce_order_product\CommerceOrderProduct;
use Hyperf\Swagger\Annotation\Property;
use Hyperf\Swagger\Annotation\Schema;

/**
 * 订单商品
 */
#[Schema(title: 'CommerceOrderProductSchema')]
class CommerceOrderProductSchema implements \JsonSerializable
{
    #[Property(property: 'order_id', title: '订单号', type: 'bigint')]
    public string $order_id;

    #[Property(property: 'commodity_id', title: '商品ID', type: 'bigint')]
    public string $commodity_id;

    #[Property(property: 'commodity_name', title: '商品名称', type: 'varchar')]
    public string $commodity_name;

    #[Property(property: 'quantity', title: '数量', type: 'int')]
    public string $quantity;

    #[Property(property: 'price', title: '单价', type: 'decimal')]
    public string $price;

    #[Property(property: 'discount', title: '折扣', type: 'decimal')]
    public string $discount;

    #[Property(property: 'reduction', title: '满减', type: 'decimal')]
    public string $reduction;

    #[Property(property: 'total_price', title: '总价', type: 'decimal')]
    public string $total_price;

    #[Property(property: 'photo', title: '照片', type: 'array')]
    public array $photo;

    #[Property(property: 'commodity_spec', title: '商品规格', type: 'array')]
    public array $commodity_spec;

    #[Property(property: 'commodity_unit', title: '商品单位', type: 'varchar')]
    public string $commodity_unit;

    #[Property(property: 'created_at', title: 'created_at', type: 'timestamp')]
    public string $created_at;

    #[Property(property: 'updated_at', title: 'updated_at', type: 'timestamp')]
    public string $updated_at;

    #[Property(property: 'deleted_at', title: 'deleted_at', type: 'timestamp')]
    public string $deleted_at;




    public function __construct(CommerceOrderProduct $model)
    {
       $this->order_id = $model->order_id;
       $this->commodity_id = $model->commodity_id;
       $this->commodity_name = $model->commodity_name;
       $this->quantity = $model->quantity;
       $this->price = $model->price;
       $this->discount = $model->discount;
       $this->reduction = $model->reduction;
       $this->total_price = $model->total_price;
       $this->photo = $model->photo;
       $this->commodity_spec = $model->commodity_spec;
       $this->commodity_unit = $model->commodity_unit;
       $this->created_at = $model->created_at;
       $this->updated_at = $model->updated_at;
       $this->deleted_at = $model->deleted_at;

    }

    public function jsonSerialize(): array
    {
        return ['order_id' => $this->order_id ,'commodity_id' => $this->commodity_id ,'commodity_name' => $this->commodity_name ,'quantity' => $this->quantity ,'price' => $this->price ,'discount' => $this->discount , 'reduction' => $this->reduction ,'total_price' => $this->total_price ,'photo' => $this->photo ,'commodity_spec' => $this->commodity_spec ,'commodity_unit' => $this->commodity_unit ,'created_at' => $this->created_at ,'updated_at' => $this->updated_at ,'deleted_at' => $this->deleted_at];
    }
}